package com.vhall.component.plugin.core.service.event;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * PAAS消息请求
 *
 * @author yuanzh
 */
@Data
@NoArgsConstructor
public class PaasMessageReqDTO implements Serializable {

    private static final long serialVersionUID = -1371601995478048831L;

    /**
     * required 频道ID
     */
    @JSONField(name = "channel_id")
    private String channelId;

    /**
     * required 消息类型，默认service_room
     */
    private String type;

    /**
     * required 消息体
     */
    private String body;
    /**
     * 消息携带的额外内容
     */
    private String context;

    /**
     * optional 客户端，默认pc_browser
     */
    private String client;

    @JSONField(name = "room_id")
    private String roomId;

    /**
     * optional 第三方用户ID，type为service_im时必填
     */
    @JSONField(name = "third_party_user_id")
    private String thirdUserId;

    /**
     * optional 默认1
     */
    @JSONField(name = "is_cache")
    private Integer isCache;

    public PaasMessageReqDTO(String channelId, String body) {
        this.channelId = channelId;
        this.body = body;
    }

    public static class Builder {

        private final PaasMessageReqDTO paasMessageReq;

        public Builder(String channel, String body) {
            this.paasMessageReq = new PaasMessageReqDTO(channel, body);
        }

        public PaasMessageReqDTO build() {
            return this.paasMessageReq;
        }

        public PaasMessageReqDTO.Builder initDefault() {
            this.paasMessageReq.setType("service_room");
            this.paasMessageReq.setClient("pc_browser");
            this.paasMessageReq.setIsCache(1);
            return this;
        }
    }
}
